<template>
    <div class="user-box">
        <van-nav-bar title="我的" fixed >
            <template #right>
                <van-icon name="fire-o" color="#ee0a24" size="20"/>
            </template>
        </van-nav-bar>
        <div class="user-info">
            <div class="info">
                <img :src="user.icon == null ? 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png': user.icon"/>
                <div class="user-desc">
                    <span>昵称：{{ user.nickname }}</span>
                    <span>登录名：{{ user.username }}</span>
                    <span class="name">个性签名：{{ user.personalized_signature == null ? '您还为填写个性签名' : user.personalized_signature }}</span>
                </div>
            </div>
        </div>
        <ul class="user-list">
            <li @click="goTo('order')">
                <span>我的订单</span>
                <van-icon name="arrow"/>
            </li>
            <li @click="goTo('setting')">
                <span>账号管理</span>
                <van-icon name="arrow"/>
            </li>
            <li @click="goTo('address?from=mine')">
                <span>地址管理</span>
                <van-icon name="arrow"/>
            </li>
            <li @click="goTo('/product-history')">
                <span>历史记录</span>
                <van-icon name="arrow"/>
            </li>
        </ul>
        <nav-bar></nav-bar>
    </div>
</template>

<script>
    import navBar from '../../components/NavBar'
    import sHeader from '../../components/SimpleHeader'
    import {getCurrent} from "../../api/user";

    export default {
        components: {
            navBar,
            sHeader
        },
        data() {
            return {
                user: {}
            }
        },
        async mounted() {
            getCurrent().then(res => {
                this.user = res.data;
            })
        },
        methods: {
            goBack() {
                this.$router.go(-1)
            },
            goTo(r) {
                this.$router.push({path: r})
            }
        }
    }
</script>


<style lang="less" scoped>
    @import '../../common/style/mixin';

    .user-box {
        .user-header {
            position: fixed;
            top: 0;
            left: 0;
            z-index: 10000;
            .fj();
            .wh(100%, 44px);
            line-height: 44px;
            padding: 0 10px;
            .boxSizing();
            color: #252525;
            background: #fff;
            border-bottom: 1px solid #dcdcdc;

            .user-name {
                font-size: 14px;
            }
        }

        .user-info {
            width: 94%;
            margin: 10px;
            height: 115px;
            /*box-shadow: 0 2px 5px #269090;*/
            border-radius: 6px;
            margin-top: 50px;
            background: #3c3b3f;  /* fallback for old browsers */      background: -webkit-linear-gradient(to right, rgb(60, 59, 63), rgb(96, 92, 60));  /* Chrome 10-25, Safari 5.1-6 */      background: linear-gradient(to right, rgb(60, 59, 63), rgb(96, 92, 60)); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */


            .info {
                position: relative;
                display: flex;
                width: 100%;
                height: 100%;
                padding: 25px 20px;
                .boxSizing();

                img {
                    .wh(60px, 60px);
                    border-radius: 50%;
                    margin-top: 4px;
                }

                .user-desc {
                    display: flex;
                    flex-direction: column;
                    margin-left: 10px;
                    line-height: 20px;
                    font-size: 14px;
                    color: #fff;

                    span {
                        color: #fff;
                        font-size: 14px;
                        padding: 2px 0;
                    }
                }

                .account-setting {
                    position: absolute;
                    top: 10px;
                    right: 20px;
                    font-size: 13px;
                    color: #fff;

                    .van-icon-setting-o {
                        font-size: 16px;
                        vertical-align: -3px;
                        margin-right: 4px;
                    }
                }
            }
        }

        .user-list {
            padding: 0 20px;
            margin-top: 20px;

            li {
                height: 40px;
                line-height: 40px;
                border-bottom: 1px solid #e9e9e9;
                display: flex;
                justify-content: space-between;
                font-size: 14px;

                .van-icon-arrow {
                    margin-top: 13px;
                }
            }
        }
    }
</style>
